Ubuntu20.04安装OpenCV3.4.16 您所在的位置:网站首页 ubuntu安装opencv 3 Ubuntu20.04安装OpenCV3.4.16

Ubuntu20.04安装OpenCV3.4.16

2024-06-03 15:24| 来源: 网络整理| 查看: 265

Ubuntu20.04安装OpenCV3.4.16 1、安装OpenCV3.4.161.1、安装包下载1.2、环境依赖配置1.3、安装1.4、测试

1、安装OpenCV3.4.16

随手记录一下,方便回看。23-04-10

1.1、安装包下载

参考: 1、Ubuntu下Opencv的安装(亲测有效,超级简单!) 2、Ubuntu18.04安装Opencv4.5(最新最详细)

1、在OpenCV官方上下载对应的安装包,然后使用samba软件把安装包传输到虚拟机中。

2、下载opencv_contrib,(注意这里要与你上面下载的opencv版本一致),用Samba软件传输到虚拟机系统中。

3、在Ubuntu中解压OpenCV文件,把opencv_contrib放到解压后opencv文件夹里面。 OpenCV解压示意图

1.2、环境依赖配置

参考Ubuntu下Opencv的安装(亲测有效,超级简单!)配置依赖:

sudo apt-get install build-essential sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev 可能报错: 在这里插入图片描述 topeet@ubuntu:~/Desktop$ sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev 正在读取软件包列表... 完成 正在分析软件包的依赖关系树 正在读取状态信息... 完成 注意,选中 'python-dev-is-python2' 而非 'python-dev' E: 无法定位软件包 libjasper-dev 解决: 根据无法定位软件包libjasper-dev的解决办法解决: 在这里插入图片描述 1.3、安装 1、在opencv文件夹下新建build文件夹,并进入build文件夹 mkdir build && cd build

在这里插入图片描述

2、在build路径下cmake sudo cmake -D CMAKE_INSTALL_PREFIX=/usr/local -D CMAKE_BUILD_TYPE=Release -D OPENCV_GENERATE_PKGCONFIG=ON -D OPENCV_ENABLE_NONFREE=True ..

注解:

CMAKE_INSTALL_PREFIX 是opencv的安装地址 默认安装在 usr/localCMAKE_BUILD_TYPE 是opencv安装的版本,Release和Debug两种可选,默认安装ReleaseOPENCV_ENABLE_NONFREE 是否使用部分被申请了专利的算方法 这里选True的话就可以使用了OPENCV_GENERATE_PKGCONFIG 强烈建议开启这个 设置为ON。 OPENCV_GENERATE_PKGCONFIG 因为opencv4默认不生成.pc文件,所以加上这句用于生成opencv4.pc文件,支持pkg-config功能。opencv4版本及以上 这里用ON

注:如果出现Built target libprotobuf的错误,将 -D ENABLE_CXX11=1 命令补充在cmake 指令后再来一次,尝试一下 。不过也不一定行 O(∩_∩)O哈哈~ ———————————————— 版权声明:本文为CSDN博主「向日葵骑士Faraday」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/KIK9973/article/details/118830187 在这里插入图片描述

3、编译 sudo make -j12

在这里插入图片描述

4、开始安装 sudo make install

在这里插入图片描述

topeet@ubuntu:~/Downloads/opencv-3.4.16/build$ sudo make install [ 1%] Built target gen-pkgconfig [ 1%] Built target ittnotify [ 9%] Built target opencv_core [ 16%] Built target opencv_imgproc [ 26%] Built target libwebp [ 34%] Built target IlmImf [ 36%] Built target opencv_imgcodecs [ 37%] Built target opencv_videoio [ 37%] Built target opencv_highgui [ 38%] Built target opencv_ts [ 41%] Built target opencv_perf_core [ 45%] Built target opencv_test_core [ 45%] Built target opencv_flann [ 45%] Built target opencv_test_flann [ 48%] Built target opencv_perf_imgproc [ 52%] Built target opencv_test_imgproc [ 53%] Built target opencv_ml [ 55%] Built target opencv_test_ml [ 57%] Built target opencv_photo [ 57%] Built target opencv_perf_photo [ 58%] Built target opencv_test_photo [ 59%] Built target opencv_video [ 60%] Built target opencv_perf_video [ 61%] Built target opencv_test_video [ 67%] Built target libprotobuf [ 74%] Built target opencv_dnn [ 74%] Built target opencv_perf_dnn [ 75%] Built target opencv_test_dnn [ 78%] Built target opencv_features2d [ 79%] Built target opencv_perf_features2d [ 81%] Built target opencv_test_features2d [ 81%] Built target opencv_perf_imgcodecs [ 82%] Built target opencv_test_imgcodecs [ 82%] Built target opencv_shape [ 82%] Built target opencv_test_shape [ 82%] Built target opencv_perf_videoio [ 83%] Built target opencv_test_videoio [ 86%] Built target opencv_calib3d [ 87%] Built target opencv_perf_calib3d [ 90%] Built target opencv_test_calib3d [ 90%] Built target opencv_test_highgui [ 91%] Built target quirc [ 92%] Built target opencv_objdetect [ 93%] Built target opencv_perf_objdetect [ 93%] Built target opencv_test_objdetect [ 95%] Built target opencv_stitching [ 96%] Built target opencv_perf_stitching [ 97%] Built target opencv_test_stitching [ 97%] Built target opencv_superres [ 97%] Built target opencv_perf_superres [ 97%] Built target opencv_test_superres [ 98%] Built target opencv_videostab [ 98%] Built target opencv_test_videostab [ 98%] Built target gen_opencv_python_source [ 98%] Built target opencv_python2 [ 99%] Built target opencv_traincascade [ 99%] Built target opencv_createsamples [ 99%] Built target opencv_annotation [ 99%] Built target opencv_visualisation [100%] Built target opencv_interactive-calibration [100%] Built target opencv_version Install the project... -- Install configuration: "Release" -- Installing: /usr/local/share/licenses/opencv3/opencl-headers-LICENSE.txt -- Installing: /usr/local/include/opencv2/cvconfig.h -- Installing: /usr/local/include/opencv2/opencv_modules.hpp -- Installing: /usr/local/lib/pkgconfig/opencv.pc -- Installing: /usr/local/share/OpenCV/OpenCVModules.cmake -- Installing: /usr/local/share/OpenCV/OpenCVModules-release.cmake -- Installing: /usr/local/share/OpenCV/OpenCVConfig-version.cmake -- Installing: /usr/local/share/OpenCV/OpenCVConfig.cmake -- Installing: /usr/local/bin/setup_vars_opencv3.sh -- Installing: /usr/local/share/OpenCV/valgrind.supp -- Installing: /usr/local/share/OpenCV/valgrind_3rdparty.supp -- Installing: /usr/local/share/licenses/opencv3/openexr-LICENSE -- Installing: /usr/local/share/licenses/opencv3/openexr-AUTHORS.ilmbase -- Installing: /usr/local/share/licenses/opencv3/openexr-AUTHORS.openexr -- Installing: /usr/local/share/licenses/opencv3/protobuf-LICENSE -- Installing: /usr/local/share/licenses/opencv3/protobuf-README.md -- Installing: /usr/local/share/licenses/opencv3/quirc-LICENSE -- Installing: /usr/local/share/licenses/opencv3/ittnotify-LICENSE.BSD -- Installing: /usr/local/share/licenses/opencv3/ittnotify-LICENSE.GPL -- Installing: /usr/local/include/opencv/cv.h -- Installing: /usr/local/include/opencv/cv.hpp -- Installing: /usr/local/include/opencv/cvaux.h -- Installing: /usr/local/include/opencv/cvaux.hpp -- Installing: /usr/local/include/opencv/cvwimage.h -- Installing: /usr/local/include/opencv/cxcore.h -- Installing: /usr/local/include/opencv/cxcore.hpp -- Installing: /usr/local/include/opencv/cxeigen.hpp -- Installing: /usr/local/include/opencv/cxmisc.h -- Installing: /usr/local/include/opencv/highgui.h -- Installing: /usr/local/include/opencv/ml.h -- Installing: /usr/local/include/opencv2/opencv.hpp -- Installing: /usr/local/lib/libopencv_core.so.3.4.16 -- Installing: /usr/local/lib/libopencv_core.so.3.4 -- Set runtime path of "/usr/local/lib/libopencv_core.so.3.4.16" to "/usr/local/lib" -- Installing: /usr/local/lib/libopencv_core.so -- Installing: /usr/local/include/opencv2/core.hpp -- Installing: /usr/local/include/opencv2/core/affine.hpp -- Installing: /usr/local/include/opencv2/core/async.hpp -- Installing: /usr/local/include/opencv2/core/base.hpp -- Installing: /usr/local/include/opencv2/core/bindings_utils.hpp -- Installing: /usr/local/include/opencv2/core/bufferpool.hpp -- Installing: /usr/local/include/opencv2/core/check.hpp -- Installing: /usr/local/include/opencv2/core/core.hpp -- Installing: /usr/local/include/opencv2/core/core_c.h -- Installing: /usr/local/include/opencv2/core/cuda.hpp -- Installing: /usr/local/include/opencv2/core/cuda.inl.hpp -- Installing: /usr/local/include/opencv2/core/cuda/block.hpp -- Installing: /usr/local/include/opencv2/core/cuda/border_interpolate.hpp -- Installing: /usr/local/include/opencv2/core/cuda/color.hpp -- Installing: /usr/local/include/opencv2/core/cuda/common.hpp -- Installing: /usr/local/include/opencv2/core/cuda/datamov_utils.hpp -- Installing: /usr/local/include/opencv2/core/cuda/detail/color_detail.hpp -- Installing: /usr/local/include/opencv2/core/cuda/detail/reduce.hpp -- Installing: /usr/local/include/opencv2/core/cuda/detail/reduce_key_val.hpp -- Installing: /usr/local/include/opencv2/core/cuda/detail/transform_detail.hpp -- Installing: /usr/local/include/opencv2/core/cuda/detail/type_traits_detail.hpp -- Installing: /usr/local/include/opencv2/core/cuda/detail/vec_distance_detail.hpp -- Installing: /usr/local/include/opencv2/core/cuda/dynamic_smem.hpp -- Installing: /usr/local/include/opencv2/core/cuda/emulation.hpp -- Installing: /usr/local/include/opencv2/core/cuda/filters.hpp -- Installing: /usr/local/include/opencv2/core/cuda/funcattrib.hpp -- Installing: /usr/local/include/opencv2/core/cuda/functional.hpp -- Installing: /usr/local/include/opencv2/core/cuda/limits.hpp -- Installing: /usr/local/include/opencv2/core/cuda/reduce.hpp -- Installing: /usr/local/include/opencv2/core/cuda/saturate_cast.hpp -- Installing: /usr/local/include/opencv2/core/cuda/scan.hpp -- Installing: /usr/local/include/opencv2/core/cuda/simd_functions.hpp -- Installing: /usr/local/include/opencv2/core/cuda/transform.hpp -- Installing: /usr/local/include/opencv2/core/cuda/type_traits.hpp -- Installing: /usr/local/include/opencv2/core/cuda/utility.hpp -- Installing: /usr/local/include/opencv2/core/cuda/vec_distance.hpp -- Installing: /usr/local/include/opencv2/core/cuda/vec_math.hpp -- Installing: /usr/local/include/opencv2/core/cuda/vec_traits.hpp -- Installing: /usr/local/include/opencv2/core/cuda/warp.hpp -- Installing: /usr/local/include/opencv2/core/cuda/warp_reduce.hpp -- Installing: /usr/local/include/opencv2/core/cuda/warp_shuffle.hpp -- Installing: /usr/local/include/opencv2/core/cuda_stream_accessor.hpp -- Installing: /usr/local/include/opencv2/core/cuda_types.hpp -- Installing: /usr/local/include/opencv2/core/cv_cpu_dispatch.h -- Installing: /usr/local/include/opencv2/core/cv_cpu_helper.h -- Installing: /usr/local/include/opencv2/core/cvdef.h -- Installing: /usr/local/include/opencv2/core/cvstd.hpp -- Installing: /usr/local/include/opencv2/core/cvstd.inl.hpp -- Installing: /usr/local/include/opencv2/core/detail/async_promise.hpp -- Installing: /usr/local/include/opencv2/core/detail/exception_ptr.hpp -- Installing: /usr/local/include/opencv2/core/directx.hpp -- Installing: /usr/local/include/opencv2/core/eigen.hpp -- Installing: /usr/local/include/opencv2/core/fast_math.hpp -- Installing: /usr/local/include/opencv2/core/hal/hal.hpp -- Installing: /usr/local/include/opencv2/core/hal/interface.h -- Installing: /usr/local/include/opencv2/core/hal/intrin.hpp -- Installing: /usr/local/include/opencv2/core/hal/intrin_avx.hpp -- Installing: /usr/local/include/opencv2/core/hal/intrin_avx512.hpp -- Installing: /usr/local/include/opencv2/core/hal/intrin_cpp.hpp -- Installing: /usr/local/include/opencv2/core/hal/intrin_forward.hpp -- Installing: /usr/local/include/opencv2/core/hal/intrin_msa.hpp -- Installing: /usr/local/include/opencv2/core/hal/intrin_neon.hpp -- Installing: /usr/local/include/opencv2/core/hal/intrin_sse.hpp -- Installing: /usr/local/include/opencv2/core/hal/intrin_sse_em.hpp -- Installing: /usr/local/include/opencv2/core/hal/intrin_vsx.hpp -- Installing: /usr/local/include/opencv2/core/hal/intrin_wasm.hpp -- Installing: /usr/local/include/opencv2/core/hal/msa_macros.h -- Installing: /usr/local/include/opencv2/core/hal/simd_utils.impl.hpp -- Installing: /usr/local/include/opencv2/core/ippasync.hpp -- Installing: /usr/local/include/opencv2/core/mat.hpp -- Installing: /usr/local/include/opencv2/core/mat.inl.hpp -- Installing: /usr/local/include/opencv2/core/matx.hpp -- Installing: /usr/local/include/opencv2/core/neon_utils.hpp -- Installing: /usr/local/include/opencv2/core/ocl.hpp -- Installing: /usr/local/include/opencv2/core/ocl_genbase.hpp -- Installing: /usr/local/include/opencv2/core/opencl/ocl_defs.hpp -- Installing: /usr/local/include/opencv2/core/opencl/opencl_info.hpp -- Installing: /usr/local/include/opencv2/core/opencl/opencl_svm.hpp -- Installing: /usr/local/include/opencv2/core/opencl/runtime/autogenerated/opencl_clamdblas.hpp -- Installing: /usr/local/include/opencv2/core/opencl/runtime/autogenerated/opencl_clamdfft.hpp -- Installing: /usr/local/include/opencv2/core/opencl/runtime/autogenerated/opencl_core.hpp -- Installing: /usr/local/include/opencv2/core/opencl/runtime/autogenerated/opencl_core_wrappers.hpp -- Installing: /usr/local/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl.hpp -- Installing: /usr/local/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl_wrappers.hpp -- Installing: /usr/local/include/opencv2/core/opencl/runtime/opencl_clamdblas.hpp -- Installing: /usr/local/include/opencv2/core/opencl/runtime/opencl_clamdfft.hpp -- Installing: /usr/local/include/opencv2/core/opencl/runtime/opencl_core.hpp -- Installing: /usr/local/include/opencv2/core/opencl/runtime/opencl_core_wrappers.hpp -- Installing: /usr/local/include/opencv2/core/opencl/runtime/opencl_gl.hpp -- Installing: /usr/local/include/opencv2/core/opencl/runtime/opencl_gl_wrappers.hpp -- Installing: /usr/local/include/opencv2/core/opencl/runtime/opencl_svm_20.hpp -- Installing: /usr/local/include/opencv2/core/opencl/runtime/opencl_svm_definitions.hpp -- Installing: /usr/local/include/opencv2/core/opencl/runtime/opencl_svm_hsa_extension.hpp -- Installing: /usr/local/include/opencv2/core/opengl.hpp -- Installing: /usr/local/include/opencv2/core/operations.hpp -- Installing: /usr/local/include/opencv2/core/optim.hpp -- Installing: /usr/local/include/opencv2/core/ovx.hpp -- Installing: /usr/local/include/opencv2/core/persistence.hpp -- Installing: /usr/local/include/opencv2/core/ptr.inl.hpp -- Installing: /usr/local/include/opencv2/core/saturate.hpp -- Installing: /usr/local/include/opencv2/core/simd_intrinsics.hpp -- Installing: /usr/local/include/opencv2/core/softfloat.hpp -- Installing: /usr/local/include/opencv2/core/sse_utils.hpp -- Installing: /usr/local/include/opencv2/core/traits.hpp -- Installing: /usr/local/include/opencv2/core/types.hpp -- Installing: /usr/local/include/opencv2/core/types_c.h -- Installing: /usr/local/include/opencv2/core/utility.hpp -- Installing: /usr/local/include/opencv2/core/utils/allocator_stats.hpp -- Installing: /usr/local/include/opencv2/core/utils/allocator_stats.impl.hpp -- Installing: /usr/local/include/opencv2/core/utils/filesystem.hpp -- Installing: /usr/local/include/opencv2/core/utils/instrumentation.hpp -- Installing: /usr/local/include/opencv2/core/utils/logger.defines.hpp -- Installing: /usr/local/include/opencv2/core/utils/logger.hpp -- Installing: /usr/local/include/opencv2/core/utils/tls.hpp -- Installing: /usr/local/include/opencv2/core/utils/trace.hpp -- Installing: /usr/local/include/opencv2/core/va_intel.hpp -- Installing: /usr/local/include/opencv2/core/version.hpp -- Installing: /usr/local/include/opencv2/core/vsx_utils.hpp -- Installing: /usr/local/include/opencv2/core/wimage.hpp -- Installing: /usr/local/share/licenses/opencv3/SoftFloat-COPYING.txt -- Installing: /usr/local/lib/libopencv_flann.so.3.4.16 -- Installing: /usr/local/lib/libopencv_flann.so.3.4 -- Set runtime path of "/usr/local/lib/libopencv_flann.so.3.4.16" to "/usr/local/lib" -- Installing: /usr/local/lib/libopencv_flann.so -- Installing: /usr/local/include/opencv2/flann.hpp -- Installing: /usr/local/include/opencv2/flann/all_indices.h -- Installing: /usr/local/include/opencv2/flann/allocator.h -- Installing: /usr/local/include/opencv2/flann/any.h -- Installing: /usr/local/include/opencv2/flann/autotuned_index.h -- Installing: /usr/local/include/opencv2/flann/composite_index.h -- Installing: /usr/local/include/opencv2/flann/config.h -- Installing: /usr/local/include/opencv2/flann/defines.h -- Installing: /usr/local/include/opencv2/flann/dist.h -- Installing: /usr/local/include/opencv2/flann/dummy.h -- Installing: /usr/local/include/opencv2/flann/dynamic_bitset.h -- Installing: /usr/local/include/opencv2/flann/flann.hpp -- Installing: /usr/local/include/opencv2/flann/flann_base.hpp -- Installing: /usr/local/include/opencv2/flann/general.h -- Installing: /usr/local/include/opencv2/flann/ground_truth.h -- Installing: /usr/local/include/opencv2/flann/hdf5.h -- Installing: /usr/local/include/opencv2/flann/heap.h -- Installing: /usr/local/include/opencv2/flann/hierarchical_clustering_index.h -- Installing: /usr/local/include/opencv2/flann/index_testing.h -- Installing: /usr/local/include/opencv2/flann/kdtree_index.h -- Installing: /usr/local/include/opencv2/flann/kdtree_single_index.h -- Installing: /usr/local/include/opencv2/flann/kmeans_index.h -- Installing: /usr/local/include/opencv2/flann/linear_index.h -- Installing: /usr/local/include/opencv2/flann/logger.h -- Installing: /usr/local/include/opencv2/flann/lsh_index.h -- Installing: /usr/local/include/opencv2/flann/lsh_table.h -- Installing: /usr/local/include/opencv2/flann/matrix.h -- Installing: /usr/local/include/opencv2/flann/miniflann.hpp -- Installing: /usr/local/include/opencv2/flann/nn_index.h -- Installing: /usr/local/include/opencv2/flann/object_factory.h -- Installing: /usr/local/include/opencv2/flann/params.h -- Installing: /usr/local/include/opencv2/flann/random.h -- Installing: /usr/local/include/opencv2/flann/result_set.h -- Installing: /usr/local/include/opencv2/flann/sampling.h -- Installing: /usr/local/include/opencv2/flann/saving.h -- Installing: /usr/local/include/opencv2/flann/simplex_downhill.h -- Installing: /usr/local/include/opencv2/flann/timer.h -- Installing: /usr/local/lib/libopencv_imgproc.so.3.4.16 -- Installing: /usr/local/lib/libopencv_imgproc.so.3.4 -- Set runtime path of "/usr/local/lib/libopencv_imgproc.so.3.4.16" to "/usr/local/lib" -- Installing: /usr/local/lib/libopencv_imgproc.so -- Installing: /usr/local/include/opencv2/imgproc.hpp -- Installing: /usr/local/include/opencv2/imgproc/detail/distortion_model.hpp -- Installing: /usr/local/include/opencv2/imgproc/hal/hal.hpp -- Installing: /usr/local/include/opencv2/imgproc/hal/interface.h -- Installing: /usr/local/include/opencv2/imgproc/imgproc.hpp -- Installing: /usr/local/include/opencv2/imgproc/imgproc_c.h -- Installing: /usr/local/include/opencv2/imgproc/types_c.h -- Installing: /usr/local/lib/libopencv_ml.so.3.4.16 -- Installing: /usr/local/lib/libopencv_ml.so.3.4 -- Set runtime path of "/usr/local/lib/libopencv_ml.so.3.4.16" to "/usr/local/lib" -- Installing: /usr/local/lib/libopencv_ml.so -- Installing: /usr/local/include/opencv2/ml.hpp -- Installing: /usr/local/include/opencv2/ml/ml.hpp -- Installing: /usr/local/include/opencv2/ml/ml.inl.hpp -- Installing: /usr/local/lib/libopencv_photo.so.3.4.16 -- Installing: /usr/local/lib/libopencv_photo.so.3.4 -- Set runtime path of "/usr/local/lib/libopencv_photo.so.3.4.16" to "/usr/local/lib" -- Installing: /usr/local/lib/libopencv_photo.so -- Installing: /usr/local/include/opencv2/photo.hpp -- Installing: /usr/local/include/opencv2/photo/cuda.hpp -- Installing: /usr/local/include/opencv2/photo/photo.hpp -- Installing: /usr/local/include/opencv2/photo/photo_c.h -- Installing: /usr/local/lib/libopencv_video.so.3.4.16 -- Installing: /usr/local/lib/libopencv_video.so.3.4 -- Set runtime path of "/usr/local/lib/libopencv_video.so.3.4.16" to "/usr/local/lib" -- Installing: /usr/local/lib/libopencv_video.so -- Installing: /usr/local/include/opencv2/video.hpp -- Installing: /usr/local/include/opencv2/video/background_segm.hpp -- Installing: /usr/local/include/opencv2/video/tracking.hpp -- Installing: /usr/local/include/opencv2/video/tracking_c.h -- Installing: /usr/local/include/opencv2/video/video.hpp -- Installing: /usr/local/lib/libopencv_dnn.so.3.4.16 -- Installing: /usr/local/lib/libopencv_dnn.so.3.4 -- Set runtime path of "/usr/local/lib/libopencv_dnn.so.3.4.16" to "/usr/local/lib" -- Installing: /usr/local/lib/libopencv_dnn.so -- Installing: /usr/local/include/opencv2/dnn.hpp -- Installing: /usr/local/include/opencv2/dnn/all_layers.hpp -- Installing: /usr/local/include/opencv2/dnn/dict.hpp -- Installing: /usr/local/include/opencv2/dnn/dnn.hpp -- Installing: /usr/local/include/opencv2/dnn/dnn.inl.hpp -- Installing: /usr/local/include/opencv2/dnn/layer.details.hpp -- Installing: /usr/local/include/opencv2/dnn/layer.hpp -- Installing: /usr/local/include/opencv2/dnn/shape_utils.hpp -- Installing: /usr/local/include/opencv2/dnn/utils/inference_engine.hpp -- Installing: /usr/local/lib/libopencv_features2d.so.3.4.16 -- Installing: /usr/local/lib/libopencv_features2d.so.3.4 -- Set runtime path of "/usr/local/lib/libopencv_features2d.so.3.4.16" to "/usr/local/lib" -- Installing: /usr/local/lib/libopencv_features2d.so -- Installing: /usr/local/include/opencv2/features2d.hpp -- Installing: /usr/local/include/opencv2/features2d/features2d.hpp -- Installing: /usr/local/include/opencv2/features2d/hal/interface.h -- Installing: /usr/local/lib/libopencv_imgcodecs.so.3.4.16 -- Installing: /usr/local/lib/libopencv_imgcodecs.so.3.4 -- Set runtime path of "/usr/local/lib/libopencv_imgcodecs.so.3.4.16" to "/usr/local/lib" -- Installing: /usr/local/lib/libopencv_imgcodecs.so -- Installing: /usr/local/include/opencv2/imgcodecs.hpp -- Installing: /usr/local/include/opencv2/imgcodecs/imgcodecs.hpp -- Installing: /usr/local/include/opencv2/imgcodecs/imgcodecs_c.h -- Installing: /usr/local/include/opencv2/imgcodecs/ios.h -- Installing: /usr/local/lib/libopencv_shape.so.3.4.16 -- Installing: /usr/local/lib/libopencv_shape.so.3.4 -- Set runtime path of "/usr/local/lib/libopencv_shape.so.3.4.16" to "/usr/local/lib" -- Installing: /usr/local/lib/libopencv_shape.so -- Installing: /usr/local/include/opencv2/shape.hpp -- Installing: /usr/local/include/opencv2/shape/emdL1.hpp -- Installing: /usr/local/include/opencv2/shape/hist_cost.hpp -- Installing: /usr/local/include/opencv2/shape/shape.hpp -- Installing: /usr/local/include/opencv2/shape/shape_distance.hpp -- Installing: /usr/local/include/opencv2/shape/shape_transformer.hpp -- Installing: /usr/local/lib/libopencv_videoio.so.3.4.16 -- Installing: /usr/local/lib/libopencv_videoio.so.3.4 -- Set runtime path of "/usr/local/lib/libopencv_videoio.so.3.4.16" to "/usr/local/lib" -- Installing: /usr/local/lib/libopencv_videoio.so -- Installing: /usr/local/include/opencv2/videoio.hpp -- Installing: /usr/local/include/opencv2/videoio/cap_ios.h -- Installing: /usr/local/include/opencv2/videoio/registry.hpp -- Installing: /usr/local/include/opencv2/videoio/videoio.hpp -- Installing: /usr/local/include/opencv2/videoio/videoio_c.h -- Installing: /usr/local/lib/libopencv_calib3d.so.3.4.16 -- Installing: /usr/local/lib/libopencv_calib3d.so.3.4 -- Set runtime path of "/usr/local/lib/libopencv_calib3d.so.3.4.16" to "/usr/local/lib" -- Installing: /usr/local/lib/libopencv_calib3d.so -- Installing: /usr/local/include/opencv2/calib3d.hpp -- Installing: /usr/local/include/opencv2/calib3d/calib3d.hpp -- Installing: /usr/local/include/opencv2/calib3d/calib3d_c.h -- Installing: /usr/local/lib/libopencv_highgui.so.3.4.16 -- Installing: /usr/local/lib/libopencv_highgui.so.3.4 -- Set runtime path of "/usr/local/lib/libopencv_highgui.so.3.4.16" to "/usr/local/lib" -- Installing: /usr/local/lib/libopencv_highgui.so -- Installing: /usr/local/include/opencv2/highgui.hpp -- Installing: /usr/local/include/opencv2/highgui/highgui.hpp -- Installing: /usr/local/include/opencv2/highgui/highgui_c.h -- Installing: /usr/local/lib/libopencv_objdetect.so.3.4.16 -- Installing: /usr/local/lib/libopencv_objdetect.so.3.4 -- Set runtime path of "/usr/local/lib/libopencv_objdetect.so.3.4.16" to "/usr/local/lib" -- Installing: /usr/local/lib/libopencv_objdetect.so -- Installing: /usr/local/include/opencv2/objdetect.hpp -- Installing: /usr/local/include/opencv2/objdetect/detection_based_tracker.hpp -- Installing: /usr/local/include/opencv2/objdetect/objdetect.hpp -- Installing: /usr/local/include/opencv2/objdetect/objdetect_c.h -- Installing: /usr/local/lib/libopencv_stitching.so.3.4.16 -- Installing: /usr/local/lib/libopencv_stitching.so.3.4 -- Set runtime path of "/usr/local/lib/libopencv_stitching.so.3.4.16" to "/usr/local/lib" -- Installing: /usr/local/lib/libopencv_stitching.so -- Installing: /usr/local/include/opencv2/stitching.hpp -- Installing: /usr/local/include/opencv2/stitching/detail/autocalib.hpp -- Installing: /usr/local/include/opencv2/stitching/detail/blenders.hpp -- Installing: /usr/local/include/opencv2/stitching/detail/camera.hpp -- Installing: /usr/local/include/opencv2/stitching/detail/exposure_compensate.hpp -- Installing: /usr/local/include/opencv2/stitching/detail/matchers.hpp -- Installing: /usr/local/include/opencv2/stitching/detail/motion_estimators.hpp -- Installing: /usr/local/include/opencv2/stitching/detail/seam_finders.hpp -- Installing: /usr/local/include/opencv2/stitching/detail/timelapsers.hpp -- Installing: /usr/local/include/opencv2/stitching/detail/util.hpp -- Installing: /usr/local/include/opencv2/stitching/detail/util_inl.hpp -- Installing: /usr/local/include/opencv2/stitching/detail/warpers.hpp -- Installing: /usr/local/include/opencv2/stitching/detail/warpers_inl.hpp -- Installing: /usr/local/include/opencv2/stitching/warpers.hpp -- Installing: /usr/local/lib/libopencv_superres.so.3.4.16 -- Installing: /usr/local/lib/libopencv_superres.so.3.4 -- Set runtime path of "/usr/local/lib/libopencv_superres.so.3.4.16" to "/usr/local/lib" -- Installing: /usr/local/lib/libopencv_superres.so -- Installing: /usr/local/include/opencv2/superres.hpp -- Installing: /usr/local/include/opencv2/superres/optical_flow.hpp -- Installing: /usr/local/lib/libopencv_videostab.so.3.4.16 -- Installing: /usr/local/lib/libopencv_videostab.so.3.4 -- Set runtime path of "/usr/local/lib/libopencv_videostab.so.3.4.16" to "/usr/local/lib" -- Installing: /usr/local/lib/libopencv_videostab.so -- Installing: /usr/local/include/opencv2/videostab.hpp -- Installing: /usr/local/include/opencv2/videostab/deblurring.hpp -- Installing: /usr/local/include/opencv2/videostab/fast_marching.hpp -- Installing: /usr/local/include/opencv2/videostab/fast_marching_inl.hpp -- Installing: /usr/local/include/opencv2/videostab/frame_source.hpp -- Installing: /usr/local/include/opencv2/videostab/global_motion.hpp -- Installing: /usr/local/include/opencv2/videostab/inpainting.hpp -- Installing: /usr/local/include/opencv2/videostab/log.hpp -- Installing: /usr/local/include/opencv2/videostab/motion_core.hpp -- Installing: /usr/local/include/opencv2/videostab/motion_stabilizing.hpp -- Installing: /usr/local/include/opencv2/videostab/optical_flow.hpp -- Installing: /usr/local/include/opencv2/videostab/outlier_rejection.hpp -- Installing: /usr/local/include/opencv2/videostab/ring_buffer.hpp -- Installing: /usr/local/include/opencv2/videostab/stabilizer.hpp -- Installing: /usr/local/include/opencv2/videostab/wobble_suppression.hpp -- Installing: /usr/local/lib/python2.7/dist-packages/cv2/__init__.py -- Installing: /usr/local/lib/python2.7/dist-packages/cv2/load_config_py2.py -- Installing: /usr/local/lib/python2.7/dist-packages/cv2/load_config_py3.py -- Installing: /usr/local/lib/python2.7/dist-packages/cv2/config.py -- Installing: /usr/local/lib/python2.7/dist-packages/cv2/python-2.7/cv2.so -- Set runtime path of "/usr/local/lib/python2.7/dist-packages/cv2/python-2.7/cv2.so" to "/usr/local/lib" -- Installing: /usr/local/lib/python2.7/dist-packages/cv2/config-2.7.py -- Installing: /usr/local/share/OpenCV/haarcascades/haarcascade_eye.xml -- Installing: /usr/local/share/OpenCV/haarcascades/haarcascade_eye_tree_eyeglasses.xml -- Installing: /usr/local/share/OpenCV/haarcascades/haarcascade_frontalcatface.xml -- Installing: /usr/local/share/OpenCV/haarcascades/haarcascade_frontalcatface_extended.xml -- Installing: /usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt.xml -- Installing: /usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt2.xml -- Installing: /usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt_tree.xml -- Installing: /usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_default.xml -- Installing: /usr/local/share/OpenCV/haarcascades/haarcascade_fullbody.xml -- Installing: /usr/local/share/OpenCV/haarcascades/haarcascade_lefteye_2splits.xml -- Installing: /usr/local/share/OpenCV/haarcascades/haarcascade_licence_plate_rus_16stages.xml -- Installing: /usr/local/share/OpenCV/haarcascades/haarcascade_lowerbody.xml -- Installing: /usr/local/share/OpenCV/haarcascades/haarcascade_profileface.xml -- Installing: /usr/local/share/OpenCV/haarcascades/haarcascade_righteye_2splits.xml -- Installing: /usr/local/share/OpenCV/haarcascades/haarcascade_russian_plate_number.xml -- Installing: /usr/local/share/OpenCV/haarcascades/haarcascade_smile.xml -- Installing: /usr/local/share/OpenCV/haarcascades/haarcascade_upperbody.xml -- Installing: /usr/local/share/OpenCV/lbpcascades/lbpcascade_frontalcatface.xml -- Installing: /usr/local/share/OpenCV/lbpcascades/lbpcascade_frontalface.xml -- Installing: /usr/local/share/OpenCV/lbpcascades/lbpcascade_frontalface_improved.xml -- Installing: /usr/local/share/OpenCV/lbpcascades/lbpcascade_profileface.xml -- Installing: /usr/local/share/OpenCV/lbpcascades/lbpcascade_silverware.xml -- Installing: /usr/local/bin/opencv_traincascade -- Set runtime path of "/usr/local/bin/opencv_traincascade" to "/usr/local/lib" -- Installing: /usr/local/bin/opencv_createsamples -- Set runtime path of "/usr/local/bin/opencv_createsamples" to "/usr/local/lib" -- Installing: /usr/local/bin/opencv_annotation -- Set runtime path of "/usr/local/bin/opencv_annotation" to "/usr/local/lib" -- Installing: /usr/local/bin/opencv_visualisation -- Set runtime path of "/usr/local/bin/opencv_visualisation" to "/usr/local/lib" -- Installing: /usr/local/bin/opencv_interactive-calibration -- Set runtime path of "/usr/local/bin/opencv_interactive-calibration" to "/usr/local/lib" -- Installing: /usr/local/bin/opencv_version -- Set runtime path of "/usr/local/bin/opencv_version" to "/usr/local/lib" 5、添加路径 打开文件: sudo nano /etc/ld.so.conf

在文件中添加如下代码: /usr/local/lib 保存关闭,运行下面代码:

sudo ldconfig

在这里插入图片描述

6、配置环境 打开.bashrc文件: sudo nano /etc/bash.bashrc

添加下面两行代码,放到最后面即可:

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export PKG_CONFIG_PATH

保存退出,终端输入:

source /etc/bash.bashrc

在这里插入图片描述

输入以下命令,可以查看所安装opencv的版本

pkg-config opencv --modversion

在这里插入图片描述 在这里插入图片描述

1.4、测试

写一个简单的测试程序test1.cpp:

#include #include using namespace cv; using namespace std; int main(int argc, char** argv) { CvPoint center; double scale = -3; IplImage* image = cvLoadImage("x1.png"); argc == 2? cvLoadImage(argv[1]) : 0; cvShowImage("Image", image); if (!image) return -1; center = cvPoint(image->width / 2, image->height / 2); for (int i = 0;iheight;i++) for (int j = 0;jwidth;j++) { double dx = (double)(j - center.x) / center.x; double dy = (double)(i - center.y) / center.y; double weight = exp((dx*dx + dy*dy)*scale); uchar* ptr = &CV_IMAGE_ELEM(image, uchar, i, j * 3); ptr[0] = cvRound(ptr[0] * weight); ptr[1] = cvRound(ptr[1] * weight); ptr[2] = cvRound(ptr[2] * weight); } Mat src;Mat dst; src = cvarrToMat(image); cv::imwrite("test.png", src); cvNamedWindow("test",1); imshow("test", src); cvWaitKey(); return 0; }

编译:

g++ test1.cpp -o test1 `pkg-config --cflags --libs opencv`

运行可执行文件:

sudo ./test1

在这里插入图片描述 报错Failed to load module "canberra-gtk-module" 参考:解决Failed to load module canberra-gtk-module错误 查看报错的模块(可有可无):

locate libcanberra-gtk-module

重新安装canberra-gtk-module:

sudo apt-get install libcanberra-gtk-module

在这里插入图片描述 不报错了,搞定!!



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有